# Which compiler
# CC = gcc
# AR = ar
# AT = @

include $(PROJ_ROOT_PATH)/config.mk

ifeq ($(shell uname -o), GNU/Linux)
	OS = -DOS_LINUX
else
	OS =
endif


OUTPUT = huawei


# source file
SRCS += main.c

OBJS = $(patsubst %.c,%.o,$(SRCS))

LIBS  = -luart
LIBS += -lpthread
LIBS += -llua
LIBS += -lm

# Where are include files kept
# INCLUDES += -Ilua_arch
# INCLUDES += -I$(BUS_PATH)/uart
# INCLUDES += -I$(MIDDLEWARE_PATH)/lua

# Option for development
CFLAGS = -g -O2 -Wall
# Option for release
# CFLAGS = -O -Wall

CFLAGS += $(OS)


$(OUTPUT): $(OBJS)
# 	$(AT)echo "LIBS: $(LIBS)"
	$(AT)$(CC) $^ -o $(BIN_PATH)$@ $(INCLUDES) $(LIBS) -L$(LIBS_PATH)
# 	$(AT)echo "$(OUTPUT) linking done"

# $(OBJS): $(SRCS)
$(OBJS):%.o:%.c
# 	$(AT)echo "SRCS: $(SRCS)"
# 	$(AT)echo "OBJS: $(OBJS)"
	$(AT)$(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@
# 	$(AT)echo "$(OBJS) compiling done"


.PHONY: clean
clean:
	$(AT)-rm -rf $(OBJS)

